<%--
  Created by IntelliJ IDEA.
  User: ZLY
  Date: 2020/12/1
  Time: 22:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="../layui/css/layui.css" />
<%--    <link rel="stylesheet" type="text/css" href="./css/style.css" />--%>
    <script src="../layui/layui.js"></script>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/layui/layui.js" charset="utf-8"></script>
</head>
<body>


<div id="right">
    <div class="layui-card" style="width: 400px">
        <div class="layui-card-header" style="width: 400px">基本信息</div>
        <div class="layui-card-body" >
            <form class="layui-form" lay-filter="information" id="information" style="margin-top: 5px">
            <button type="submit" class="layui-btn layui-btn-primary" lay-submit="" layui-filter="formdemo" id="xiugai" style="float: right;right: 20px ;"> <i class="layui-icon" style="border: 0px" ></i></button>
                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="id" class="layui-input" disabled>
                    </div>
                </div>

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" class="layui-input" >
                    </div>
                </div>
                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">电话</label>
                    <div class="layui-input-inline ">
                        <input type="text" name="iphone" class="layui-input" >
                    </div>
                </div>

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-inline ">
                        <input type="password" name="pwd" class="layui-input" >
                    </div>
                </div>

                <div class="layui-form-item layui-row" style="margin-bottom: 2px">
                    <label class="layui-form-label">身份证号</label>
                    <div class="layui-input-inline ">
                        <input type="text" name="idcard" class="layui-input" disabled>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>



<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;
    });
    layui.use(['table','form'], function(){
        var table = layui.table;
        var $ = layui.jquery;
        var form = layui.form;
        $(function () {
            getinformation();
            xiugaixinxi();
        })
        function getinformation(){
            $.ajax({
                url:'${pageContext.request.contextPath}/User/queryAll',
                type:"post",
                dataType:'JSON',
                success:function (d){
                    //alert(d);
                  if (d!=null){
                      form.val('information',d);
                    //  form.var(d);
                   //   alert(d);
                   //   alert("返回成功,有值");
                  }
                }
            });
        }

        function xiugaixinxi() {
            $("#xiugai").click(function () {
                var xinxi=form.val('information');
                alert(typeof JSON.stringify(xinxi));
                alert(JSON.stringify(xinxi));
                $.ajax({
                    url:'${pageContext.request.contextPath}/User/update',
                    dataType: "JSON",
                    data: xinxi,
                   // data:xinxi,
                    type: 'post',
                    success:function (d) {
                        layui.alert("修改信息成功！！！");

                        if(d>0){
                            layui.alert("修改信息成功！！！");
                        }
                    },errors:function () {
                        alert("服务器故障！！！！！！111")
                    }
                })
            })
        }
    });

</script>
</body>
</html>


